﻿@model IEnumerable<Package>
@{
    var _context = WebSiteContext.Current;
    Layout = "~/Views/Shared/_Dashboard.cshtml";
    var curTheme = _context.DataContext.Themes.Find(p => p.Name.Equals(_context.Web.Theme, StringComparison.OrdinalIgnoreCase));
}
@UIHelper.ImageTitle(Html.Global("RES_THEME"), Html.Global("SiteSettings_Themes_Tips"), Url.Content("~/content/images/icon_theme_48.png"))
@UIHelper.SectionHeader(Html.Global("ThemeSettings_CurrentTheme"))
@if (curTheme != null)
{
    <table>
        <tr>
            <td style="width: 200px; vertical-align: top; text-align: center;">
                @{var _img = curTheme.Images.FirstOrDefault();}
                @if (_img != null)
                {
                    <img src="@curTheme.ResolveUrl(_img.Url)" alt="@GE.GetContent(curTheme.Title)" />
                }
                else
                { 
                    <img src="@Url.Content("~/content/images/img_theme_nopreview.jpg")" alt="no-preview" />
                }
                <div style="padding-top: 20px;">
                    @Ajax.Dna().Button().LocText("RES_SAVE").ImageIcons(Url.Content("~/content/images/icon_save.gif")).Click("window.open(\"" + Url.Action("Download", new { name = curTheme.Name }) + "\");").GetHtml()
                </div>
            </td>
            <td style="vertical-align: top;">
                @UIHelper.PackageInfo(curTheme)
            </td>
        </tr>
    </table>
}
@UIHelper.SectionHeader(Html.Global("ThemeSettings_BrowseThemes"))
@foreach (var pkg in Model)
{
    if (curTheme != null)
    {
        if (pkg.Name.Equals(curTheme.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
    }

    if (pkg != null)
    {
    <table>
        <tr>
            <td style="width: 200px; vertical-align: top;padding-top:10px; text-align: center;">
                @{var _img = pkg.Images.FirstOrDefault();}
                @if (_img != null)
                {
                    <img src="@pkg.ResolveUrl(_img.Url)" alt="@pkg.Title" />
                }
                else
                {
                    <img src="@Url.Content("~/content/images/img_theme_nopreview.jpg")" alt="no-preview" />
                }
                <div style="padding-top: 20px;">
                    @Ajax.Dna().Button().LocText("RES_APPLY").ImageIcons(Url.Content("~/content/images/icon_accept_16.png")).Click("$(\"#selTheme\").val(\"" + pkg.Name + "\");$(\"#themeForm\").submit();").GetHtml()
                    @Ajax.Dna().Button().LocText("RES_SAVE").ImageIcons(Url.Content("~/content/images/icon_save.gif")).Click("window.open(\"" + Url.Action("Download", new { name = pkg.Name }) + "\");").GetHtml()
                </div>
            </td>
            <td style="vertical-align: top;">
                @UIHelper.PackageInfo(pkg)
            </td>
        </tr>
    </table>
    }
}
<form method="post" action="@Url.Action("List", new { Area = "", website = _context.Web.Name })" id="themeForm">
@Html.AntiForgeryToken()
<input id="selTheme" name="Theme" type="hidden" />
</form>
